import request from '@/utils/request'
const UpmsUserServices = {
  actions: {
    /**
     * 用户分页
     */
    userPage({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('user/page', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 用户新增
     */
    userSave({ commit }, params) {
      console.log(JSON.stringify(params))
      return new Promise((resolve, reject) => {
        request.post('user/save', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 用户修改
     */
    userUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('user/update/' + params.id, {
          'roleId': params.roleId,
          'gender': params.gender,
          'avatar': params.avatar,
          'userName': params.userName,
          'realName': params.realName,
          'mobile': params.mobile,
          'email': params.email,
          'weixin': params.weixin,
          'idNumber': params.idNumber,
          'remarks': params.remarks
        }).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 用户删除
     */
    userRemove({ commit }, ids) {
      return new Promise((resolve, reject) => {
        request.post('user/remove', ids).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    }
  }
}
export default UpmsUserServices
